/* ******************************************************** */
/* Arcans Project (2010)                                    */
/* Jeu sous forme d'application web entièrement conçu       */
/* et réalisé par Killian Le Maitre                         */
/* Jeu sous licence GNU GPL v3 (voir NOTICE et COPYING)     */
/* ******************************************************** */

//classe javascript de l'éditeur
var obj_edit_class = function () {
	//constructeur :
	this.constructor = function (numero) {
		this.numero = numero;
		this.html_niv = true;
		this.textarea_div = document.getElementById("text" + this.numero);
		this.enteteFunT();
		this.zone = document.createElement("div");
		this.zone.setAttribute("class", "zonediv");
		this.textarea_div.appendChild(this.zone);
	}
	//propriétés :
	this.textarea_div;
	this.entete;
	this.zone;
	this.numero;
	//méthodes :
	this.buttonFun = function (bouton) {
		var crea_button = document.createElement("input");
		crea_button.setAttribute("type", "button");
		crea_button.setAttribute("class", "button");
		switch (bouton) {
			case "bold" :
				crea_button.setAttribute("value", "B");
				crea_button.setAttribute("onclick", "javascript:obj_edit"+this.numero+".bold();");
				break;
			case "italic" :
				crea_button.setAttribute("value", "I");
				crea_button.setAttribute("onclick", "javascript:obj_edit"+this.numero+".italic();");
				break;
				//
			case "html" :
				crea_button.setAttribute("value", "HTML");
				crea_button.setAttribute("onclick", "javascript:obj_edit"+this.numero+".htmlFun(1);");
				break;
		}
		this.entete.appendChild(crea_button);
	}
	this.enteteFunT = function () {
		this.entete = document.createElement("div");
		this.entete.setAttribute("class", "entete");
		this.buttonFun("bold"); //bouton bold
		this.buttonFun("italic"); //bouton italic
		//
		this.buttonFun("html"); //bouton html
		//
		this.textarea_div.appendChild(this.entete);
	}
	this.enteteFunF = function () {
		this.entete = document.createElement("div");
		this.entete.setAttribute("class", "entete");
		crea_button = document.createElement("input");
		crea_button.setAttribute("type", "button");
		crea_button.setAttribute("class", "button");
		crea_button.setAttribute("value", "Rédaction");
		crea_button.setAttribute("onclick", "javascript:obj_edit" + this.numero + ".htmlFun(0);");
		this.entete.appendChild(crea_button);
		this.textarea_div.appendChild(this.entete);
	}
	this.bold = function () {
		//
		alert ("mise en gras non intégrée");
		//
	}
	this.htmlFun = function (niveau) {
		if (niveau) {
			this.textarea_div.removeChild(this.entete);
			this.textarea_div.removeChild(this.zone);
			this.enteteFunF();
			//
			//
			this.zone = document.createElement("textarea");
			this.zone.setAttribute("class", "zonetex");
			this.textarea_div.appendChild(this.zone);
		}
		else {
			this.textarea_div.removeChild(this.entete);
			this.textarea_div.removeChild(this.zone);
			this.enteteFunT();
			//
			//
			this.zone = document.createElement("div");
			this.zone.setAttribute("class", "zonediv");
			this.textarea_div.appendChild(this.zone);
		}
	}
}
//lancement après le chargement de la page
var obj_edit1 = new obj_edit_class();
var obj_edit2 = new obj_edit_class();
var obj_edit3 = new obj_edit_class();
window.setTimeout('obj_edit1.constructor(1);', 700);
window.setTimeout('obj_edit2.constructor(2);', 700);
window.setTimeout('obj_edit3.constructor(3);', 700);